package com.qubuyer.business.mine.viewmodel

import com.qubuyer.core.ext.toast
import com.qubuyer.core.http.RetrofitCall
import java.io.File

class SettingViewModel : UserViewModel() {

    fun loginOut(block: () -> Unit) {
        RetrofitCall<String?>(lifecycleOwner, this) {
            api { authModel.logout() }
            success {
                block.invoke()
            }
        }
    }

    fun updateHeadImg(file: File) {
        RetrofitCall<String?>(lifecycleOwner, this) {
            api { authModel.updateHeadImage(file) }
            success {
                lifecycleOwner?.toast("更新头像成功");
                getUserInfo()
            }
        }
    }
}